{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Histograms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In a histogram, the height of each bar (bin) represents the number of data points that fall into its interval. They are generally used to show the distribution of a variable.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Generate some random data\n",
    "import random\n",
    "from beakerx import *\n",
    "data1 = []\n",
    "data2 = []\n",
    "\n",
    "for x in range(1, 10000):\n",
    "  data1.append(random.gauss(0, 1))  \n",
    "  data2.append(2*random.gauss(0, 1) + 1.0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(data= data1, binCount= 25)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(\n",
    "    initWidth=800,\n",
    "    initHeight=200,\n",
    "              title=\"Wide Histogram with Manual Parameters\",\n",
    "              xLabel=\"Size\",\n",
    "              yLabel=\"Count\",\n",
    "              rangeMin= -8, \n",
    "              rangeMax= 8, \n",
    "              data= data1,\n",
    "              binCount= 99, \n",
    "              color= Color(0, 154, 166))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(title= \"Default is Overlap\",\n",
    "              data=  [data1, data2],\n",
    "              binCount=  99,\n",
    "              names= [\"old and tired\", \"new and improved\"],\n",
    "              color= [Color(0, 154, 166),\n",
    "                      Color(230, 50, 50, 128) # transparent!\n",
    "                     ])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(title= \"Stack\",\n",
    "              showLegend= False,\n",
    "              displayMode= Histogram.DisplayMode.STACK,\n",
    "              data= [data1, data2],\n",
    "              binCount= 99)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(title= \"Side by Side\",\n",
    "              displayMode=  Histogram.DisplayMode.SIDE_BY_SIDE,\n",
    "              data = [data1,data2], \n",
    "              binCount= 55)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(title= \"Cumulative\",\n",
    "              cumulative= True,\n",
    "              data= data1,\n",
    "              binCount= 55)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(title= \"Normed, Area = 1.0\",\n",
    "              normed= True,\n",
    "              data= data1,\n",
    "              binCount= 55)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Histogram(log= True, data= data1, binCount= 99)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
